/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.model.disc.shape;

import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IVector;


/**
*A class representing a shape function for the element L2.
*
*@author Lucas, Marcelo & Pitangueira, Roque
*@version 1.0
*@since Jully 2004
*/

public class L2 extends Shape1D 
{
	private static final long serialVersionUID = 1L;

	/** Constructs a shape function for linear element L2 and sets its type to "L2".*/
	public L2() 
	{
		type = "L2";
	}
	
//********************************************************************************
	
	/** Returns the IVector containing the values of shape function evalueted in provided points.
	*@param g The vector containing the coordinates which the shape function will be evalueted.
	*@return The IVector containing the values of shape function evalueted in provided points.
	*/
	public IVector getShapeFunction(double[] g) 
	{
		double a = g[0];
		
		IVector n = new IVector(2);
		
		double n0 = ((0.5)*(1-a));
		double n1 = ((0.5)*(1+a));
		
		n.setElement(0,n0);
		n.setElement(1,n1);
		
		return (n);
	}
	
//********************************************************************************
	
	/** Returns the IMatrix containing the values of shape function derived in xi and eta evalueted in provided points.
	*@param g The vector containing the coordinates which the shape function will be evalueted.
	*@return The IMatrix containing the values of shape function derived with respect to xi and evalueted in provided points.
	*/
	public IMatrix getDerivedShapeFunction(double[] g) 
	{
		IMatrix dl = new IMatrix(1,2);
		
	//derivadas em relacao a xi (a = xi e b = eta)
		double dl0 = ((-1)*(0.5));
		double dl1 = ((0.5));
		
		//derivadas em relacao a xi na linha 0 da IMatrix
		dl.setElement(0,0,dl0);
		dl.setElement(0,1,dl1);
		
		return (dl);
	}
	
//********************************************************************************
	
	/** Return the IMatrix containing nodal coordinates of this shape in natural system.
	*@return natCoords The IMatrix with nodal coordinates of this shape in natural system.
	*/
	public IMatrix getNaturalNodalCoords()
	{
		IMatrix natCoords = new IMatrix(1,2);
		
	//coordenadas naturais de xi
		natCoords.setElement(0,0,-1);
		natCoords.setElement(0,1,1);
		
			return natCoords;
	}
	
//********************************************************************************

}

